<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title></title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta name="keywords" content="2023年中职技能竞赛
聊城、德州、滨州、东营四市联赛
“婴幼儿保育”赛项">
    <meta name="description" content="2023年中职技能竞赛
聊城、德州、滨州、东营四市联赛
“婴幼儿保育”赛项">
    <link rel="stylesheet" href="/js/layui/css/layui.css">
    <!-- Bootstrap CSS File -->
    <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/examination/common.css">
    <link rel="shortcut icon" href="">
    <style>
        .marR10 {
            width: 22px;
            height: 20px;
            display: block;
            float: left;
            margin: 17px 10px 0 0;
        }
        .mar10{
            margin-top: 0 !important;
            margin-left: auto;
            font-size: 18px !important;
        }
        .mar10:hover {
            background: #efefef;
        }

        label {
            display: block;
            line-height: 50px !important;
        }
        label{
            margin-bottom: 0 !important;
        }
        a {
            color: #666;
        }

        #layui-layer1 .layui-layer-btn{
            text-align: center;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn0{
            background: #FF6A66;
            color: #fff;
            border: none;
            font-size: 14px;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn1{
            background: white;
            border:1px solid #FF6A66;
            font-size: 14px;
        }

        .div-1{
            margin: 50px auto;
            width: 200px;
            margin-left: 300px;
        }
        .infoBox {
            background: none !important;
        }
        .signin {
            /*background: url("../../../img/indexlogin.png") no-repeat;*/
            background-size: 100% 100%;
        }
        .info {
            width: 95% !important;
            display: flex !important;
            margin: 20px 40px !important;
            margin-bottom: 50px !important;
            justify-content: space-between;
        }
        .around {
            width: 95%;
            display: flex;
            justify-content: space-between;
        }
        .sheet {
            box-sizing: border-box;
            padding: 24px 20px;
            padding-bottom: 0;
            background: #ffffff;
            border-radius: 20px;

        }
        .onenape {
            font-weight: bold;
        }
        .topic {
            width: 100%;
            height: calc(100vh - 295px);
            margin-bottom: 20px;
            /*padding: 24px 24px;*/
            border-radius: 20px;
            background: #FFFFFF;
        }
        .left-ss {
            width: 0 ;
            flex: 1;
            /*margin-top: -28px;*/
            box-sizing: border-box;
        }
        .mar10 {
            width: 95% !important;
            margin-left: 55px !important;
            overflow: hidden;
        }
        .mar10:hover {
            width: 95% !important;
        }
        #name {
            font-size: 30px;
        }
        #loginBtnColor {
            margin: 0 auto !important;

        }
        .btnBox {
            width: 78%;
            display: flex;
            justify-content: center;
        }
        .heading {
            width: 0 !important;
            background: rgba(255,255,255,0.5);
            margin-right: 50px;
            margin-bottom: 20px !important;
            float: right !important;
        }
        #examShowtime {
            margin: 0;
        }
        .textconfig {
            border:1px solid #ccc;
            width:100%;
            height:200px;
            line-height: 20px;
            font-size: 16px;
            padding: 10px;
            border-radius:5px
        }

        #btnUpload {
            float:left;
            text-align: center;
            margin-top: 80px;
            margin-left: 60px
        }
        #btnUpload img {
            background: #fdfdef;
            border: 1px solid #f5efd8;
            width: 150px;height: 150px
        }
        #btnUpload p {
            font-size: 14px;
            margin-top: 10px;
            font-weight: bold;
            font-size: 18px
        }
        #btnUpload span {
            font-size: 14px;
            width: 100px;
            height: 100px
        }

        #btnUploadimg {
            float:left;
            text-align: center;
            margin-left: 30px;
            display: none;
            margin-top: 80px
        }

        #btnUploadimg .bgimg {
            background: #fdfdef;
            border: 1px solid #f5efd8;
            width: 150px;height: 150px
        }
        #btnUploadimg p {
            font-size: 17px;
            width:150px;
            margin-top: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #iconClose{
            margin-top: -145px;
            margin-left: -25px;
        }
        #examinationLoginImage {
            position: relative !important;
        }
        .redlogos {
            display: flex;
            align-items: center;
            position: absolute;
            top: 0%;
            left: 3%;
            width: 74%;
        }

        .marVideo:hover{
            background: none;
        }

        .resourceUrlVideo{
            width: 100%;
            margin-top: 20px;
        }
        .mar10{
            width: 100%;
        }
        .resourceUrlVideo video{
            width: 90%;
            height:calc(100vh - 660px);
            margin: 0 auto;
            display: block;
        }

        #examinationLogoImg {
            display: none; /* 隐藏图片 */
        }
        #examinationLogoImg[src] {
            display: block; /* 显示图片 */
        }
        .query{
            padding: 0 60px;
            margin: 0;
        }
        .alerted .button {
            width: 100%;
            margin: 0 auto;
            text-align: center;
        }
        .alerted .button span {
            margin-right: 0;
        }
        .alerted{
            width: 520px;
            height: 270px;
            padding: 0 0 36px 0;
            background: #fff;
        }
        .alerted .title{
            font-size: 14px !important;
            border: 1px solid #E9E9E9;
            color: #333;
            height: 40px;
            line-height: 40px;
            text-align: left;
            padding: 0 24px;
            background: #F9F9F9;
            display: flex;
            align-items: center;

        }
        .alerted span{
            flex: 1;
        }
        .alerted img{
           width: 16px;
           height: 16px;
           cursor: pointer;
        }
        .layui-input{
            background: #ffffff;
            padding-left: 18px;
            margin: 24px auto;
            width: 80%;
            height: 42px;
            line-height: 42px;
            font-size: 14px !important;
        }
        /*#sub,.serial{*/
        /*    background: #FB5E58 !important;*/
        /*}*/
        /*单选按钮选中后增加的样式*/
        label{
            margin-bottom: 0 !important;
        }
        #loginBtnColor{
            width: 200px;
            height: 48px;
            border-radius: 5px;
            padding: 0;
            text-align: center;
            color: #fff;
            font: 18px/48px "";
            float: left;
        }
    </style>
</head>
<body id="excessiveImage" class="signin" style="overflow-x: hidden">
<div class="redlogos">
<!--    <img id="examinationLogoImg"  style="width: 13%;height: 86px;object-fit: contain;" >-->
<!--    <h1 id="titleText"></h1>-->
</div>
<div class="infoBox">
    <div class="info">
        <div class="redlogo"></div>
        <div class="attributes">
            <h1 id="roomNumber"></h1>
            <h1 id="seatNumber"></h1>

            <div id="idCard"></div>
            <div id="ticketNumber"></div>
            <h1 id="name" style="margin-top: 15px"></h1>
            <button style="margin-top: 14px;font-size: 20px;margin-right: 10px;line-height: 50px" class="btn btn-block titleText" id="next" onclick="maximize();"><img style="width: 50px;margin-right: 10px" src="./../../img/fulls.png" />全屏</button>
        </div>
    </div>
</div>


<div class="timseadd" style="display:none;">
    <div class="" id="examShowtime" >
        <img style="margin-left: -30px;margin-top: -5px;width: 74px;" src="../../img/countDown.png">
        <span>本次竞赛剩余</span>
        <span id="lastEndTime"></span>
    </div>
</div>

<div class="around">
    <div class="left-ss">
        <div class="topic">
            <div class="subjectType">
                <img style="width: 20px;margin-top: -9px;margin-right: 2px" src="../../img/energy.png">
                <span class="subjectTypeText">单项选择题</span>
            </div>
            <div class="login_panel" style="width: 100%;font-size:20px;height:calc(100vh - 345px);padding: 0 45px">
                <div id="content">
                </div>

                <div class="adjust">
                    <div class="btnBox">
                        <button class="btn btn-block not-allowed unify" onClick="first();">第一题</button>
                        <button class="btn btn-block not-allowed unify gray"  onClick="pre();">上一题</button>
                        <button class="btn btn-block not-allowed unify green" onClick="next();">下一题</button>
                        <button class="btn btn-block unify" onClick="last();">最后一题</button>
                    </div>

                </div>
            </div>
        </div>
        <div style="background: #FFFFFF;float: left;width: 100%;border-radius: 20px;padding: 36px 0;">
            <input id="loginBtnColor" type="button" class="btn btn-block not-allowed resetSub" onclick="question(this);" value="交卷"/>
        </div>
    </div>



    <div class="sheet">
        <div class="rt_content_tt">
            <h2>答题卡</h2>
        </div>
        <div class="state"> <p class="done"><span class="bgspan"></span>已做</p> <p class="done fail"><span></span>未做</p> </div>
        <p class="onenape">单项选择题</p>
        <div class="rt_content_nr answerSheet">
            <ul id="answer"></ul>
        </div>
        <p class="onenape">多项选择题</p>
        <ul id="choice"></ul>
        <p class="onenape">判断题</p>
        <ul id="questionsBox"></ul>
        <p class="onenape asBox">案例分析题</p>
        <ul id="case"></ul>
        <p class="onenape zdzh">制定照护计划</p>
        <ul id="nurse"></ul>
        <p class="onenape zqjy">早期教育保教活动分析</p>
        <ul id="activity"></ul>
    </div>

</div>


</div>

<div class="alerted">
    <p class="title">
        <span>提示</span>
        <img src="../../img/closes.png" id="closeClick">
    </p>
    <p class="query">
        您还有<span class="questionNum"></span>题未答完，是否确定交卷？
        <br>
        如果确定交卷，请输入二次加密号进行再次确认
    </p>
    <input type="text" id="num2" class="ti4 layui-input" placeholder="请输入二次加密号" autocomplete="new-password"
           class="ti4 layui-input">
    <div class="button">
        <span onclick="submitDate()">确定</span>
        <!--        <span onclick="submitDate()">坚持提交</span>-->
        <!--        <span onclick="continuest()">继续考试</span>-->
        <!--        <span onclick="submitDate()">坚持提交</span>-->
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="/js/layui/layui.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"
        th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="/js/plugins/validate/messages_zh.min.js" th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript" src="/js/webJs/defaultConfig/style.config.js"></script>
<script type="text/javascript">

    $().ready(function() {
        cteated(101)
        cteated(102)
        cteated(204)
        cteated(205)
        cteated(302)
        cteated(303)
        cteated(401)
        cteated(403)
        cteated(402)
    });
    let as = null
    let nurse =null
    let activity =null
    //f5、f12、f11禁用
    document.oncontextmenu=new Function("event.returnValue=false");
    document.onselectstart=new Function("event.returnValue=false");

    //f12、f11禁用
    // document.onkeydown = function (e) {
    //     var ev = window.event || e;
    //     var code = ev.keyCode || ev.which;
    //     if (123 || 122 ||  115) {
    //         if(ev.preventDefault) {
    //             ev.preventDefault();
    //         } else {
    //             ev.keyCode = 0;
    //             ev.returnValue = false;
    //         }
    //     }
    // };
    document.addEventListener("keydown", function(event) {
        // 检查按下的键是否为 F11 或 F12
        if (event.key === "F11" || event.key === "F12") {
            event.preventDefault();  // 阻止默认行为
        }
    });
    document.addEventListener("mousedown", function(event) {
        if(event.button === 1) { // 检测鼠标中键
            event.preventDefault(); // 阻止默认行为
        }
    });
    // window.addEventListener('beforeunload',function(event){
    //     let e = event || window.event;
    //     e.preventDefault();
    //     if( e ){
    //         e.returnValue = '';
    //         return false;
    //     }
    // })

    $(document).ready(function() {
        var intro = JSON.parse(localStorage.getItem("intro"));
        if(intro === null) {
            let name = info.name
            let ticketNumber = info.ticketNumber
            let idNumber = info.idCard
            location.href = '/examination/endExam?name='+name+'&ticketNumber='+ticketNumber+'&idNumber='+idNumber;
        }
        $('#closeClick').click(function(){
            $('.alerted').hide()
        })

    });


    var exam = JSON.parse(window.localStorage.getItem("exam"));
    var info = JSON.parse(window.localStorage.getItem("info"));
    var dates = JSON.parse(window.localStorage.getItem("dates"));//
    var dates1 = dates * 60;

    var allowNum = info.allowNum; // 允许三次切屏，超过则提交

    function maximize(){
        var el = document.documentElement;
        fullScreen(el);
    }

    window.onclick = document.onclick = function (e) {
        var el = document.documentElement;
        //这里的 el 可以是其他的页面元素，这样实现的就是这个元素的全屏，而不是整个页面的全屏
        fullScreen(el);
    };
    function fullScreen(el) {
        var rfs = el.requestFullScreen || el.webkitRequestFullScreen ||

            el.mozRequestFullScreen || el.msRequestFullScreen;

        if (typeof rfs != "undefined" && rfs) {

            rfs.call(el);

        } else if (typeof window.ActiveXObject != "undefined") {

            //for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏

            var wscript = new ActiveXObject("WScript.Shell");

            if (wscript != null) {

                wscript.SendKeys("{F11}");

            }

        }
    }

    //单选 多选 切换
    $(".tap").find('dd').click(function (){
        let idx;
        $(this).addClass('active').siblings().removeClass('active');
        if( $(this).attr('data-type') == '1' ){
            $(".subjectTypeText").text('单项选择题');
            idx = $("#answer").find('li').eq(0).attr('data-index');
            index = idx;
            changeCss(idx)
        }else{
            $(".subjectTypeText").text('多项选择题');
            idx = $("#choice").find('li').eq(0).attr('data-index');
            index = idx;
            if( idx > 0 ){
                $(".gray").css('background','#43BD00').attr('disabled',false);
            }

            changeCss(idx)
        }
    })


    // $('#sub').attr("title" , "考试时间大于"+dates+"分钟才能交卷！");

    //题目总数
    var allsubject = '';
    var index = 0;
    $(function () {
        // $("#roomNumber").html("考场号：" + info.roomNumber);
        // $("#seatNumber").html("座位号：" + info.seatNumber);
        $("#name").html("二次加密序号：" + info.num2);
        // $("#name").html("姓名：" + info.name);
        // $("#idCard").html("考生编号：" + info.idCard);
        // $("#ticketNumber").html("准考证号：" + info.ticketNumber);
        //$("#photo").attr("src", info.photo);
        $("#stuSignId").val(info.stuSignId);
        $("#epaperId").val(exam.id);
        //倒计时
        $.ajax({
            type: "POST",
            url: "/jzApi/examinations/getNowDateTime",
            data: {},
            success: function (r) {
                //console.log("map =" , r.data.endTime);
                window.localStorage.setItem("nowDate",r);
                countDown();
            }
        });


        function addZero(i) {
            return i < 10 ? "0" + i : i + "";
        }
        var set;
        function countDown() {

            var nowTime = new Date(window.localStorage.getItem("nowDate").replace(/-/g,"/"));
            window.localStorage.setItem("nowDate",new Date(nowTime.getTime()+1000));
            var info = JSON.parse(window.localStorage.getItem("info"));
            //监督员设置了延时
            if( info.endDate != undefined ){
                var endTime = new Date(info.endDate.replace(/-/g, "/")); //考试结束时间
                //console.log("endTime11",endTime)
            }else{
                var endTime = new Date(JSON.parse(window.localStorage.getItem("intro")).endTime.replace(/-/g, "/")); //考试结束时间
            }
            if( window.localStorage.getItem("endTime") !=undefined ){
                var endTime =new Date(window.localStorage.getItem("endTime").replace(/-/g, "/"));
            }
            var leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000);
            // var d = parseInt(lefTtime / (24*60*60))
            var h = parseInt(leftTime / (60 * 60) % 24);
            var m = parseInt(leftTime / 60 % 60);
            var s = parseInt(leftTime % 60);
            // d = addZero(d)
            h = addZero(h);
            m = addZero(m);
            s = addZero(s);
            document.querySelector("#lastEndTime").innerHTML = h + ':' + m + ':' +  s ;

            // if (info.name.indexOf("jzwy")!=-1||leftTime <= dates1) {
            //     $("#sub").attr("disabled", false);
            //     $("#sub").removeClass("not-allowed");
            // }

            set = setTimeout(countDown, 1000);
            if (leftTime < 0) {
                // submit();
                // clearInterval(set);
                // return
            }

        }

        getData(0);

        layui.use(['upload','element'], function () {
            var upload = layui.upload;
            var element = layui.element;
            upload.render({
                elem: '#btnUpload',
                url: '/common/sysFile/upload',
                // timeout: 36000000,
                // size: 1024 * 100,
                accept: 'file',
                // exts: 'docx|doc|xlsx|pdf|ppt',
                choose: function(obj){
                    $('.progress-me').show()
                    var files = obj.pushFile();
                    var data = files
                    var values = Object.values(data);
                    for (let i = 0; i < values.length; i++) {
                        name = values[i].name
                    }
                    var keys = Object.keys(obj.pushFile());
                    var lastKey = keys[keys.length - 1];
                    for (const valuesKey in obj.pushFile()) {
                        if (valuesKey !== lastKey) {
                            delete obj.pushFile()[valuesKey];
                        }
                    }
                },
                progress: function(n, elem, e){ // 上传进度回调
                    if(n == 99 || n == 100) {
                        element.progress('demo', `${99}%`)
                    }else {
                        element.progress('demo', `${n}%`)
                    }
                },
                done: function (r) {
                    if(r.code == "500") {
                        layer.msg(r.msg);
                        $('.progress-me').hide()
                        return
                    }
                    if(r.code === '200') {
                        element.progress('demo', `${100}%`)
                    }
                    $("#btnUploadimg").show()
                    $(".btnUploadimgtext").attr('title',r.data)
                    $(".btnUploadimgtext").html(name);
                    $('.progress-me').hide()
                    element.progress('demo', `${0}%`)
                    $('#nurse').children().addClass('hasBeenAnswer')
                },
                error: function (r) {
                    layer.msg(r.msg);
                    $('.progress-me').hide()
                    element.progress('demo', `${0}%`)
                }
            });

        });

        // 删除上传的文件
        let close = document.getElementById('iconClose')
        if(close) {
            close.onclick = function () {
                $("#btnUploadimg").hide()
                $(".btnUploadimgtext").attr('title','')
                $(".btnUploadimgtext").html('');
                $('.progress-me').hide()
            }
        }


        //渲染答题卡选中状态
        $('.mar10').click(function () {
            var that = $(this);
            var examId = that.parents('.titleEaxm').attr('data-id');
            var type = that.parents('.titleEaxm').attr('type');
            /*根据题目ID找到对应答题卡*/
            var cardLi = $('li[data-id=' + examId + ']');
            //多选题
            if (type == 1) {
                var a = true;//控制答题卡是否选中
                var b = false;//判断选项是否选中
                if (!that.find("input").prop('checked')) {
                    that.siblings(".mar10").each(function () {
                        //选择了一个选项则为true
                        if ($(this).find("input").prop('checked')) {
                            b = true
                        }
                    });

                } else {
                    b = true;
                }
                if (a) {
                    if (b) {
                        cardLi.addClass('hasBeenAnswer');
                    } else {

                        cardLi.removeClass('hasBeenAnswer');
                    }
                } else {
                    cardLi.removeClass('hasBeenAnswer');
                }
            }
            else if( type != 4 ){
                if (!cardLi.hasClass('hasBeenAnswer')) {

                    cardLi.addClass('hasBeenAnswer');
                }
            }

            $(this).find('textarea').change(function (e){
                if( e.target.value ){
                    if ( type == 4 ) {
                        if (!cardLi.hasClass('hasBeenAnswer')) {

                            cardLi.addClass('hasBeenAnswer');
                        }
                    }
                }else{
                    cardLi.removeClass('hasBeenAnswer');
                }
            })

        });
        //
        //点击答题卡跳转题目
        $('.anLi').click(function () {


            // 答题卡选中
            const domTitle = $(this)['context'].title
            if(domTitle === '案例分析题') {
                $(this).addClass('hasBeenAnswer')
                let textBox = [{id:$(this).attr('data-id') ,value:"1",type:"4"}]
                window.localStorage.setItem("textBox", JSON.stringify(textBox));
            }

            if(domTitle === '早期教育保教活动分析') {
                $(this).addClass('hasBeenAnswer')
                let textBox = [{id:$(this).attr('data-id') ,value:"1",type:"6"}]
                window.localStorage.setItem("textBoxVideo", JSON.stringify(textBox));
            }


            if($(this).attr('data-type') == 1){
                $(".subjectTypeText").text('多项选择题');
                $(".tap").find('dd').eq(1).addClass('active').siblings().removeClass('active');
            }

            if($(this).attr('data-type') == 0){
                $(".subjectTypeText").text('单项选择题');
                $(".tap").find('dd').eq(0).addClass('active').siblings().removeClass('active');
            }

            if ($(this).attr('data-type') == 4) {
                $(".subjectTypeText").text('案例分析题部分');
            }
            if ($(this).attr('data-type') == 5 ) {
                $(".subjectTypeText").text('制定照护计划');
            }
            if ($(this).attr('data-type') == 6 ) {
                $(".subjectTypeText").text('早期教育保教活动分析');
            }
            if ($(this).attr('data-type') == 2) {
                $(".subjectTypeText").text('判断题');
            }

            index = $(this).attr('data-index');

            if( index >= exam.questions.length - 1){
                $(".green").css('background','#ccc').attr('disabled',true);
            }else{
                $(".green").css('background','#43BD00').attr('disabled',false);
            }

            if( index <= 0){
                $(".gray").css('background','#ccc').attr('disabled',true);
            }else{
                $(".gray").css('background','#43BD00').attr('disabled',false);
            }

            toGo(index)
        });
        //答案存入缓存
        $("input").change(function () {
            var answerList = [];
            var subject = '';
            $('.titleEaxm').each(function (i, res) {
                var that = $(this);
                var che = '';
                var type = that.find("input").attr("type");
                //单选、判断
                if (type == 'radio') {
                    var rad = '';
                    if (that.find($('input:checked')).val() != '' && that.find($('input:checked')).val() != undefined) {
                        rad = that.find($('input:checked')).val().substring(0, 1)
                    }
                    answerList.push({id: that.attr("data-id"), value: rad,type:that.attr('type')});
                } else if (type == 'checkbox') { //多选
                    that.find('input:checkbox:checked').each(function (i) {
                        if ($(this).val() != '') {
                            che += $(this).val().substring(0, 1) + ';;'
                        }
                        // che.push($(this).val());
                    });
                    answerList.push({id: that.attr("data-id"), value: che,type:that.attr('type')});
                }
                //进度显示
                if (that.find($('input:checked')).val() != undefined) {
                    subject = subject * 1 + 1
                }
            });
            //题目完成进度
            var process = (subject / allsubject) * 100;
            $("#process").html("共" + allsubject + "道题目，已完成" + process.toFixed(2) + "%");

            window.localStorage.setItem("answerList", JSON.stringify(answerList));
            //console.log("answerList",answerList)
            //未完成题目数量
            window.localStorage.setItem("incomplete", allsubject - subject);
        });
        //从缓存取出答案、遍历到页面
        var answerList = window.localStorage.getItem("answerList");
        if (null != answerList) {
            var subject = '';
            var answerListJSON = JSON.parse(answerList);
            //遍历题目
            $('.titleEaxm').each(function () {
                var that = $(this);
                for (var i = 0; i < answerListJSON.length; i++) {
                    //根据id找到对应题目
                    if (that.attr("data-id") == answerListJSON[i].id) {
                        if (answerListJSON[i].value != '') {
                            $('li[data-id=' + answerListJSON[i].id + ']').addClass('hasBeenAnswer');
                        }
                        //判断是否多选
                        if (answerListJSON[i].value.indexOf(";;") != -1) {
                            //遍历多选题答案
                            var valueList = answerListJSON[i].value.split(";;");
                            //遍历选项
                            that.find("input").each(function () {
                                for (var j = 0; j < valueList.length; j++) {
                                    //根据答案找到选项，并渲染选中效果到页面
                                    if ($(this).val().substring(0, 1) == valueList[j]) {
                                        $(this).attr("checked", "checked");
                                    }
                                }
                            });
                        } else {
                            that.find("input").each(function () {
                                //根据答案找到选项，并渲染选中效果到页面
                                if ($(this).val().substring(0, 1) == answerListJSON[i].value) {
                                    $(this).attr("checked", "checked");
                                }
                            });
                        }
                        break;
                    }
                }
                //进度显示
                if (that.find($('input:checked')).val() != undefined) {
                    subject = subject * 1 + 1
                }
            });
            //题目完成进度
            var process = (subject / allsubject) * 100;
            //未完成题目数量
            window.localStorage.setItem("incomplete", allsubject - subject);
            $("#process").html("共" + allsubject + "道题目，已完成" + process.toFixed(2) + "%");
        }else{
            window.localStorage.setItem("incomplete", allsubject);
        }

        $("textarea").change(function () {
            let textBox = []
            $('.titleEaxm').each(function (i, res) {
                var that = $(this);
                var che = '';
                var type = that.find("textarea").attr("type");
                //文本框
                if (type == 'text') {
                    if (that.find($('textarea')).val() != '' && that.find($('textarea')).val() != undefined) {
                        textBox.push({
                            id: that.attr("data-id"),
                            value: that.find($('textarea')).val(),
                            type: that.attr('type')
                        });
                    }
                }
            });
            window.localStorage.setItem("textBox", JSON.stringify(textBox));
        });

        //从缓存取出答案、遍历到页面
        var textBox = window.localStorage.getItem("textBox");
        if (null != textBox) {
            var subject = '';
            var textBoxJSON = JSON.parse(textBox);
            //遍历题目
            $('.titleEaxm').each(function () {
                var that = $(this);
                for (var i = 0; i < textBoxJSON.length; i++) {
                    //根据id找到对应题目
                    if (that.attr("data-id") == textBoxJSON[i].id) {
                        if (textBoxJSON[i].value != '') {
                            $('li[data-id=' + textBoxJSON[i].id + ']').addClass('hasBeenAnswer');
                        }
                        // //判断空值
                        if (textBoxJSON[i].value != '' && that.find($('textarea')).val() != undefined) {
                            //遍历多选题答案
                            var valueList = textBoxJSON[i].value;
                            $(this).find('textarea').val(valueList)
                            break;
                        }
                    }
                    //进度显示
                    if (that.find($('input:checked')).val() != undefined) {
                        subject = subject * 1 + 1
                    }
                }
                //题目完成进度
                var process = (subject / allsubject) * 100;
                //未完成题目数量
                window.localStorage.setItem("incomplete", allsubject - subject);
                $("#process").html("共" + allsubject + "道题目，已完成" + process.toFixed(2) + "%");
            })
        } else {
            window.localStorage.setItem("incomplete", allsubject);
        }

        //从缓存取出答案、遍历到页面
        var textBoxVideo = window.localStorage.getItem("textBoxVideo");
        if (null != textBoxVideo) {
            var subject = '';
            var textBoxJSON = JSON.parse(textBoxVideo);
            //遍历题目
            $('.titleEaxm').each(function () {
                var that = $(this);
                for (var i = 0; i < textBoxJSON.length; i++) {
                    //根据id找到对应题目
                    if (that.attr("data-id") == textBoxJSON[i].id) {
                        if (textBoxJSON[i].value != '') {
                            $('li[data-id=' + textBoxJSON[i].id + ']').addClass('hasBeenAnswer');
                        }
                        // //判断空值
                        if (textBoxJSON[i].value != '' && that.find($('textarea')).val() != undefined) {
                            //遍历多选题答案
                            var valueList = textBoxJSON[i].value;
                            $(this).find('textarea').val(valueList)
                            break;
                        }
                    }
                }
            })
        }

    });


    function submitDate(){
        if($('#num2').val()==''){
            layer.msg("二次加密号不能为空")
            return false
        }
        if($('#num2').val()!=info.num2){
            layer.msg("二次加密号不正确")
            return false
        }
        submit();
    }

    function continuest(){
        $(".alerted").hide();
    }

    function question() {

        var intro = JSON.parse(localStorage.getItem("intro"));
        // 考试开始时间 加半个小时
        var startTime = new Date(intro.startTime).getTime() + (60*30*1000);
        //当前时间
        var thisTime = new Date(window.localStorage.getItem("nowDate").replace(/-/g,"/"));
        //考试结束时间
        var endTime = new Date(intro.endTime).getTime();

        let isTrue = JSON.parse(localStorage.getItem('isTrue'));
        //     let isTrue = true;
        // if( isTrue ){
        //
        //     // $(".alerted").show();
        //
        //     $('.titleEaxm').each(function (i, res) {
        //         tBox.push({id: $(res).attr('data-id'), value: $(res).find('.subject').val(), type: $(res).attr("type")});
        //     })
        //
        //     tBox.forEach(function (val){
        //         if( !val.value ){
        //             $(".alerted").show();
        //             return false;
        //         }
        //     })
        //
        //     submit();
        //
        // }else{
        //     if( thisTime > startTime ){
        //         isvalue()
        //
        //     }else if( endTime - thisTime <= (60*30*1000) ){
        //         // $(".alerted").show();
        //         isvalue()
        //     }else{
        //         isvalue()
        //         // layer.confirm("考试还未满30分钟,不能交卷", {
        //         //     btn: ['确定', '取消']
        //         // })
        //     }
        // }
        isvalue()
    }

    function isvalue() {
        const answerList =JSON.parse(window.localStorage.getItem("answerList")) ;
        const alList = JSON.parse(window.localStorage.getItem("textBox"))
        const videoList = JSON.parse(window.localStorage.getItem("textBoxVideo"))
        let arr = []
        if(alList !== null) {
            videoList ? arr = [...alList,...videoList] : ''
        }


        if(answerList !== null) {
            // for (let i = 0; i < answerList?.length; i++) {
            //     if(answerList[i].value ==="") {
            //         $(".alerted").show();
            //         console.log('alerted','alerted')
            //         return false
            //     }else{
            //         console.log('submit','submit')
            //        // submit();
            //     }
            // }

            let allValuesExist = answerList.every(function(item){
                return item.value !== ''
            });
            console.log('allValuesExist',allValuesExist)
            if (allValuesExist) {
                console.log('提交11111')
                submit();
            }else{
                let emptyValues = answerList.filter(function(item){
                    return item.value == ''
                } );

                $('.questionNum').html(emptyValues.length)
                console.log("val值为空的元素个数为：" + emptyValues.length);
                $(".alerted").show();
            }

            // if(alList !== null) {
            //     for (let i = 0; i < alList?.length; i++) {
            //         if(alList[i].value ==="") {
            //             $(".alerted").show();
            //             return
            //         }else {
            //             submit()
            //         }
            //     }
            // }else {
            //     if(as.length !==0) {
            //         $(".alerted").show();
            //         return
            //     }
            //     submit();
            // }

        }else {
            $('.questionNum').html(allsubject)
            $(".alerted").show();
        }

    }

    //获取题目数据
    function getData(titleNumber) {
        var a = '<div>';//题目
        var c = '';//切换按钮
        var an = [];//单选答题卡
        var am = [];//多选答题卡
        as = [];//案例分析答题卡
        nurse = [] //制定照护答题卡
        activity = [] // 早期教育保教活动分析
        var ab = [];//判断题
        allsubject = exam.questions.length;
        $("#process").html("共" + allsubject + "道题目，已完成0%");
        var arr =exam.questions;
        var t;
        for(var i = 0;i < arr.length; i++){
            var rand = parseInt(Math.random()*arr.length);
            t = arr[rand];
            arr[rand] =arr[i];
            arr[i] = t;
        }
        arr.forEach(function (item, index, arr) {
            //渲染答题卡
            if (item.type == 1) {
                am.push(item)
                // am += '<li class="anLi"  data-index="' + index + '" data-id="' + item.id + '"><a href="#">' + (parseInt(index)+1) + '</a></li>';
            }else if (item.type == 4) {
                as.push(item)
            }
            else if( item.type == 2 ){
                ab.push(item)
                // an += '<li class="anLi"  data-index="' + index + '" data-id="' + item.id + '"><a href="#">' + (parseInt(index)+1) + '</a></li>';
                // 制定照护
            }else if(item.type === '5'){
                nurse.push(item)
            }else if(item.type === '6') {
                activity.push(item)
            }else{
                an.push(item)
            }
        })
        var convan = [];
        convan = an.concat(am,ab);
        convan.forEach(function (item,index,arr){
            //控制题目展示
            if (titleNumber == index) {
                f = 'contentBoxShow box'
            } else {
                f = 'contentBoxHide box'
            }
            var list = item.options.split(";;");
            //     var pre = index-1;
            //     var next = index+1;
            var last = arr.length - 1;
            var b = '', d = '', e = '';

            //判断题目类型，写入题目描述
            if (item.type == 0) {  //单选
                if (item.resourceType == 0) {

                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="radio" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '" value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>" + item.introduce+ "</span>" + '</div>' + b;

                }else if(item.resourceType == 1){
                    //写入图片题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="radio" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '" value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>"  + item.introduce+ "</span>"  + '<img style="width: 500px;height: auto;" src="'+item.resourceUrl+'">' +'</img>'+ '</div>' + b;


                }else if(item.resourceType == 2){
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="radio" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '" value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>" + item.introduce+ "</span>" + '</div>' + b;

                }
            }
            //判断题目类型，写入题目描述
            if (item.type == 2) { //判断
                if (item.resourceType == 0) {
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="radio" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '"  value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float: left' class='bold'>" + item.introduce+ "</span>" + '</div>' + b;

                }else    if (item.resourceType == 1) {
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="radio" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '"  value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float: left' class='bold'>" + item.introduce+ "</span>" + '<img style="width: 500px;height: auto;" src="'+item.resourceUrl+'">' +'</img>'+  '</div>' + b;

                }


            }
            if (item.type == 1) {  //多选
                if (item.resourceType == 0) {
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="checkbox" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '" value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '"  data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>" + item.introduce+ "</span>" + '</div>' + b;


                }else if(item.resourceType == 1){
                    //写入题目选项
                    for (var i = 0; i < list.length; i++) {
                        b += '<div class="mar10"><input type="checkbox" class="marR10 subject" id="' + item.id + '_' + i + '" name="' + item.id + '" value="' + list[i] + '" />'
                            + '<label for="' + item.id + '_' + i + '">' + list[i] + '</label></div>'
                    }
                    a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '"  data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>" + item.introduce+ "</span>" + '<img style="width: 500px;height: auto;" src="'+item.resourceUrl+'">' +'</img>'+  '</div>' + b;

                }

            }

            //当前题目为第一题则不能点击上一题，为最后一题不能点击下一题
            if (index == 0) {
                d = '<button class="btn btn-block not-allowed" disabled onclick="pre();">上一题</button>'
            } else {
                d = '<button class="btn btn-block" id="pre" onclick="pre();">上一题</button>'
            }
            if (index == last) {
                e = '<button class="btn btn-block not-allowed" disabled onclick="next();">下一题</button>'
            } else {
                e = '<button class="btn btn-block" id="next" onclick="next();">下一题</button>'
            }
            c = '<div class="div-1 changeBtn" style="display:flex;justify-content:space-between;margin:40px 0 100px 0">' +
                '<button class="btn btn-block" onclick="first();">第一题</button>' +
                d +
                e +
                '<button class="btn btn-block" onclick="last();">最后一题</button></div>';
            a += c;
            a += '</div>';
            // }
        });

        let bs = '', bstr = '';

        // 案例分析题判断隐藏
        if(as.length === 0) {
            $('.asBox').hide()
            $('#case').hide()
        }

        //制定照护计划题目判断、
        if(nurse.length === 0) {
            $('.zdzh').hide()
            $('#nurse').hide()
        }


        // 早期教育保教活动分析
        if(activity.length === 0) {
            $('.zqjy').hide()
            $('#activity').hide()
        }

        let imgbt = ""
        as.forEach(function (item, index, arr) {
            //案例分析应用题
            if (item.type == 4) { //案例应用题
                if (item.resourceType == 0) {
                    //写入题目选项
                    bs += '<div class="mar10" style="display: none"><textarea type="text" placeholder="请输入您的回答" class="subject textidValue textconfig" id="' + item.id + '_' + i + '" name="' + item.id + '" ></textarea>'
                        + '</div>'
                }else if(item.resourceType == 1) {
                    item.resourceUrlArr?.forEach(function (arr) {
                        imgbt += `<img style='max-width: 80%;height: auto;margin: 10px 0' src="${arr}" />`
                    })
                }else if(item.resourceType == 2) {
                    bs += `<div class="resourceUrlVideo">
                                <video preload="auto" src="${item.resourceUrl}" controls></video>
                                <p style="background: #F3F6FB;text-align: center;margin-top: 20px;font-size: 20px;padding: 10px 0;">请选手在纸质答题卷上作答</p>
                           </div>
                       `;
                }

                bstr += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + (convan.length + index) + '"><div style="display:flex;justify-content: center;flex-wrap: wrap">' + "<span class='serial'>" + (parseInt((convan.length)) + 1) + "</span>" + "<span style='float: left;white-space: pre-wrap' class='bold'>" +  item.introduce + "</span>" + imgbt + '</div>' + bs ;

            }

        })

        a += bstr;
        $("#content").html(a);


        let updata = ""
        let yyzh = ''
        nurse.forEach(function (item, index, arr) {
            //制定照护
            if (item.type === '5') {
                updata = `
                    <div style="width: 100%;;height: 10px;border-bottom: 1px dashed #b7c4df;float: left;margin-left: 60px;margin-top:60px"></div>
                    <div id="btnUpload">
                        <img src="/img/updatass.png">
                        <p>点击上传</p>
                        <input type="text" style="opacity:0;width: 1px;" id="fileRoute"
                               name="fileRoute"/>
                        <span id="test" name="test"></span>
                        <div style="display: none" class="layui-progress layui-progress-big progress-me" lay-showpercent="true" lay-filter="demo">
                            <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
                        </div>
                    </div>
                    <div id="btnUploadimg">
                        <img class="bgimg" src="/img/sssppt.png">
                            <img id="iconClose" src="/img/close.png"></img>
                        </img>
                        <p class="btnUploadimgtext"></p>
                    </div>
                `

                // a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + convan.length + index +1 + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span style='float:left' class='bold'>" + item.introduce+ "</span>" + '</div>' + b;
                yyzh += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + (parseInt(an.length + am.length + ab.length  +as.length+ index) + 1) + '"><div style="display:flex;justify-content: align-items:stretch;flex-wrap: wrap">' + "<span class='serial'>" + (parseInt(an.length + am.length + ab.length  +as.length+ index) + 1)+ "</span>" + "<span style='float: left;white-space;' class='bold'>" +  item.introduce + "</span>" + updata + '</div>';
            }

        })

        $("#content").children().append(yyzh)

        let updatas = ""
        let bzhd = ''
        let templates = ""
        activity.forEach(function (item, index, res) {
            //早期教育保教活动分析
            if (item.resourceType === '0') {
                //写入题目选项
                bzhd += '<div class="mar10" style="display: none"><textarea type="text" placeholder="请输入您的回答" class="subject textidValue textconfig" id="' + item.id + '_' + i + '" name="' + item.id + '" ></textarea>'
                    + '</div>'
            }else if(item.resourceType === '1') {
                item.resourceUrlArr?.forEach(function (res) {
                    updatas += `<img style='max-width: 80%;height: auto;margin: 10px 0' src="${res}" />`
                })
            }else if(item.resourceType === '2') {
                bzhd += `<div class="resourceUrlVideo">
                                <video preload="auto" src="${item.resourceUrl}" controls></video>
                                <p style="background: #F3F6FB;text-align: center;margin-top: 20px;font-size: 20px;padding: 10px 0;">请选手在纸质答题卷上作答</p>
                           </div>
                       `;
            }

            templates += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + (arr.length) + '"><div style="display:flex;justify-content: center;flex-wrap: wrap">' + "<span class='serial'>" + (parseInt(arr.length)) + "</span>" + "<span style='float: left;white-space: pre-wrap' class='bold'>" +  item.introduce + "</span>" + updatas + '</div>' + bzhd ;

        })


        $("#content").children().append(templates)



        var str = '';
        an.map(function (item,index){
            str += '<li  class="anLi" id="examinationColor"  data-type=" '+ item.type +'" data-index="' + index + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(index)+1) + '</a></li>';
        })

        $("#answer").html(str)  //答题卡

        str = '';
        am.map(function (item,index){
            str += '<li  class="anLi" id="examinationColor" data-type=" '+ item.type +'"  data-index="' + (parseInt(an.length + index)) + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(an.length + index)+1) + '</a></li>';
        })

        $("#choice").html(str)  //答题卡

        // 案例分析题
        str = '';
        as.map(function (item, index) {
            str += '<li class="anLi" id="examinationColor" title="案例分析题" data-type=" ' + item.type + '"  data-index="' + (parseInt(an.length + am.length + ab.length + index )) + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(an.length + am.length + ab.length + index) + 1) + '</a></li>';
        })

        $("#case").html(str)  //答题卡

        str = '';
        ab.map(function (item, index) {
            str += '<li class="anLi" id="examinationColor" data-type=" ' + item.type + '"  data-index="' + (parseInt(an.length + am.length + index)) + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(an.length + am.length + index) + 1) + '</a></li>';
        })
        $("#questionsBox").html(str)  //答题卡

        // 制定照护计划
        str = '';
        nurse.map(function (item, index) {
            str += '<li class="anLi" id="examinationColor" title="制定照护计划" data-type=" ' + item.type + '"  data-index="' + (parseInt(an.length + am.length + ab.length  +as.length+ index)) + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(an.length + am.length + ab.length  +as.length+ index) + 1) + '</a></li>';
        })
        $("#nurse").html(str)  //答题卡

        // 早期教育保教活动分析
        str = '';
        activity.map(function (item, index) {
            str += '<li class="anLi" id="examinationColor" title="早期教育保教活动分析" data-type="'+ item.type + '"  data-index="' + (parseInt(arr.length-1)) + '" data-id="' + item.id + '"><a  href="#">' + (parseInt(arr.length)) + '</a></li>';
        })
        $("#activity").html(str)  //答题卡

    }

    function toGo(index) {
        changeCss(index)
    }

    function first() {
        index = 0;
        $(".gray").css('background','#ccc').attr('disabled',true);
        $(".green").css('background','#43BD00').attr('disabled',false);

        if($('.titleEaxm').eq(index).attr('type') == "1"){
            $(".subjectTypeText").text('多项选择题');
            $(".tap").find('dd').eq(1).addClass('active').siblings().removeClass('active');
        }else{
            $(".subjectTypeText").text('单项选择题');
            $(".tap").find('dd').eq(0).addClass('active').siblings().removeClass('active');
        }

        if($('.titleEaxm').eq(index).attr('type') == "4"){
            $(".subjectTypeText").text('案例分析题部分');
        }
        if($('.titleEaxm').eq(index).attr('type') == "6"){
            $(".subjectTypeText").text('案例分析题部分');
        }

        changeCss(index)
    }

    function last() {
        index = exam.questions.length - 1;
        $(".gray").css('background','#43BD00').attr('disabled',false);
        $(".green").css('background','#ccc').attr('disabled',true);

        if($('.titleEaxm').eq(index).attr('type') == "1"){
            $(".subjectTypeText").text('多项选择题');
            $(".tap").find('dd').eq(1).addClass('active').siblings().removeClass('active');
        }else{
            $(".subjectTypeText").text('单项选择题');
            $(".tap").find('dd').eq(0).addClass('active').siblings().removeClass('active');
        }
        if($('.titleEaxm').eq(index).attr('type') == "4"){
            $(".subjectTypeText").text('案例分析题部分');

            addClass()


        }
        if($('.titleEaxm').eq(index).attr('type') == "5"){
            $(".subjectTypeText").text('制定照护计划');

            addClass()

        }
        if($('.titleEaxm').eq(index).attr('type') == "6"){
            $(".subjectTypeText").text('早期教育保教活动分析');

            addClass()

        }
        if ($('.titleEaxm').eq(index).attr('type') == 2) {
            $(".subjectTypeText").text('判断题');
        }
        changeCss(index)
    }

    function addClass() {
        // 添加类名
        const domul = $('#case')[0].children
        for (let i = 0; i < domul.length; i++) {
            if(domul[0].title === '案例分析题') {
                $(domul[i]).addClass('hasBeenAnswer');
                let textBox = [{id:$(domul[i]).attr('data-id') ,value:"1",type:"4"}]
                window.localStorage.setItem("textBox", JSON.stringify(textBox));
            }
        }
    }

    function next() {
        index = parseInt(index) + parseInt(1);

        if( index > 0 ){
            $(".gray").css('background','#43BD00').attr('disabled',false);
        }
        if( index >= exam.questions.length ){
            $(".green").css('background','#ccc').attr('disabled',true);
            index = exam.questions.length - 1;
        }else {
            $(".green").css('background','#43BD00');
        }

        if($('.titleEaxm').eq(index).attr('type') == "1"){
            $(".subjectTypeText").text('多项选择题');
            $(".tap").find('dd').eq(1).addClass('active').siblings().removeClass('active');
        }else{
            $(".subjectTypeText").text('单项选择题');
            $(".tap").find('dd').eq(0).addClass('active').siblings().removeClass('active');
        }
        if($('.titleEaxm').eq(index).attr('type') == "4"){
            $(".subjectTypeText").text('案例分析题部分');
            addClass()
        }
        if($('.titleEaxm').eq(index).attr('type') == "5"){
            $(".subjectTypeText").text('制定照护计划');
            addClass()
        }
        if($('.titleEaxm').eq(index).attr('type') == "6"){
            $(".subjectTypeText").text('早期教育保教活动分析');
            addClass()
        }
        if ($('.titleEaxm').eq(index).attr('type') == 2) {
            $(".subjectTypeText").text('判断题');
        }

        changeCss(index)
    }

    function pre() {
        index = parseInt(index) - parseInt(1);

        if( index < exam.questions.length){
            $(".green").css('background','#43BD00').attr('disabled',false);
        }
        if( index <= 0 ){
            $(".gray").css('background','#ccc').attr('disabled',true);
            index = 0;
        }else {
            $(".gray").css('background','#43BD00');
        }

        if($('.titleEaxm').eq(index).attr('type') === '0'){
            $(".subjectTypeText").text('单项选择题');
            $(".tap").find('dd').eq(0).addClass('active').siblings().removeClass('active');
        }

        if( $('.titleEaxm').eq(index).attr('type') == "1" ){
            $(".subjectTypeText").text('多项选择题');
            $(".tap").find('dd').eq(1).addClass('active').siblings().removeClass('active');
        }

        if ($('.titleEaxm').eq(index).attr('type') === '2') {
            $(".subjectTypeText").text('判断题');
        }
        if ($('.titleEaxm').eq(index).attr('type') === '4') {
            $(".subjectTypeText").text('案例分析题');
        }
        if ($('.titleEaxm').eq(index).attr('type') === '5') {
            $(".subjectTypeText").text('制定照护计划');
        }
        if ($('.titleEaxm').eq(index).attr('type') === '6') {
            $(".subjectTypeText").text('早期教育保教活动分析');
        }
        changeCss(index)
    }
    //刷新考试结束时间
    function reload() {
        $.ajax({
            url: "/jzweb/exceptionAddtime/delayed",
            data: {stuId:JSON.parse(window.localStorage.getItem("info")).stuSignId,eBatchId:JSON.parse(window.localStorage.getItem("intro")).id },
            success: function (r) {

                let info = JSON.parse(window.localStorage.getItem("info"));
                info.endDate = r.data.endTime;
                window.localStorage.setItem('isTrue', JSON.stringify(r.data.isTrue));
                window.localStorage.setItem("endTime",r.data.endTime);
                window.localStorage.setItem("info",JSON.stringify(info));
            }
        });
    }

    //控制题目展示
    function changeCss(index) {
        console.log(index)
        $('.box').each(function (i, res) {
            if (index == i) {
                $(this).addClass("contentBoxShow");
                $(this).removeClass("contentBoxHide");
            } else {
                $(this).addClass("contentBoxHide");
                $(this).removeClass("contentBoxShow")
            }
        });

    }
    // 去重函数
    function uniqueArray(arr) {
        const resultMap = new Map();

        for (const obj of arr) {
            if (!resultMap.has(obj.id)) {
                resultMap.set(obj.id, obj);
            } else {
                const existingObj = resultMap.get(obj.id);
                if (!existingObj.value && !existingObj.type && (obj.value || obj.type)) {
                    resultMap.set(obj.id, obj);
                }
            }
        }

        return Array.from(resultMap.values());
    }

    //提交答卷
    function submit() {

        // var t = Math.round(Math.random());
        //0-9随机数
        var t = Math.floor(Math.random() * 10);
        //console.log("answerList", JSON.stringify(answerList));
        // var answerList = JSON.parse(window.localStorage.getItem("answerList"));
        var answerList = window.localStorage.getItem("answerList");
        var textBox = window.localStorage.getItem("textBox");
        var tolBox = [];
        var examBatchId;
        var id = layer.msg('提交中，请等待！', {
            icon: 16,
            shade: 0.4,
            time: false //取消自动关闭
        });

        if( !answerList ){
            answerList = [];
            $('.titleEaxm').each(function (i, res){
                answerList.push({id : $(res).attr('data-id'),value :'',type:$(res).attr("type")});
            })
            answerList = JSON.stringify(answerList);
        }

        if (!textBox) {
            textBox = [];
            $('.titleEaxm').each(function (i, res) {
                textBox.push({id: $(res).attr('data-id'), value: '', type: $(res).attr("type")});
            })
            textBox = JSON.stringify(textBox);
        }

        answerList = JSON.parse(answerList);
        textBox = JSON.parse(textBox);
        tolBox =  [...answerList,...textBox];
        tolBox = JSON.stringify(uniqueArray(tolBox));
        // type ==1  现在的题目(应用分析题)
        // type ==2  理论题
        setTimeout(function () {
            $.ajax({
                type: "POST",
                url:  "/jzApi/examinations/selAnswerSheet",
                data: {
                    stuSignId: info.stuSignId,
                    epaperId: exam.id,
                    answerList: tolBox,
                    code: info.cookieCode,
                    file: $(".btnUploadimgtext").attr('title') ?? ''
                    // type: '4'
                },
                success: function (r) {
                    //console.log("r",r)
                    if (r.code == 0) {
                        //提交试卷后清除缓存
                        var name = info.name
                        var ticketNumber = info.ticketNumber
                        var idNumber = info.idCard
                        // localStorage.removeItem("info");
                        localStorage.removeItem("exam");
                        localStorage.removeItem("intro");
                        localStorage.removeItem("answerList");
                        localStorage.removeItem("endTime");
                        localStorage.removeItem("dates");
                        localStorage.removeItem("incomplete");
                        localStorage.removeItem("times");
                        localStorage.removeItem("endTimes");
                        localStorage.removeItem("textBox");
                        // localStorage.clear();
                        location.href = '/examination/endExam?name='+name+'&ticketNumber='+ticketNumber+'&idNumber='+idNumber;
                        // location.reload()
                        parent.layer.close(id)
                    } else {
                        layer.msg(r.msg);
                        location.href = '/examination/endExam?name='+name+'&ticketNumber='+ticketNumber+'&idNumber='+idNumber;
                        // location.reload()
                        parent.layer.close(id)
                    }
                }
            });
        }, t * 1000);
    }
</script>
</body>